package com.homegoods.home.fragments;

import android.os.Bundle;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.homegoods.aroutercomment.ARouterPath;
import com.homegoods.home.R;
import com.homegoods.home.databinding.HomeFragmentWebviewBinding;
import com.kedll.library.fragment.KBaseFragment;
import com.kedll.library.mvp.BasePresenter;
import com.tencent.smtt.export.external.interfaces.WebResourceRequest;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;

/**
 * 首页广告webview
 */
@Route(path = ARouterPath.PATH_HOME_WEBVIEW)
public class HomeWebFragment extends KBaseFragment<HomeFragmentWebviewBinding, BasePresenter> {
//    public WebView wvDetail;
//    private WebSettings websettings;


    @Override
    protected void init() {
        super.init();
//        wvDetail = mBinding.homeWebview;

    }

    @Override
    protected void initEvent(Bundle savedInstanceState) {
        String url = "www.baidu.com";
        if (getArguments() != null) {
            url = getArguments().getString("url");
        }
//        wvDetail.setFocusable(false);
//        wvDetail.loadUrl(url);
//        websettings = wvDetail.getSettings();
//        websettings.setLoadWithOverviewMode(true);
//        websettings.setBuiltInZoomControls(true);
//        websettings.setLoadsImagesAutomatically(true);
//        websettings.setRenderPriority(WebSettings.RenderPriority.HIGH);
//        websettings.setBlockNetworkImage(true);
//        websettings.setUseWideViewPort(true);
//        websettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
//        wvDetail.setWebViewClient(new GoodsDetailWebViewClient());
    }


    @Override
    protected BasePresenter getPresenter() {
        return null;
    }


//    private class GoodsDetailWebViewClient extends WebViewClient {
//
//        @Override
//        public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
//            return true;
//        }
//
//        @Override
//        public void onPageFinished(WebView view, String url) {
//            super.onPageFinished(view, url);
////            websettings.setBlockNetworkImage(false);
//        }
//    }

    @Override
    protected int getLayout() {
        return R.layout.home_fragment_webview;
    }
}
